package org.netty.im.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.netty.im.common.ChatConstants;
import org.netty.im.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@Controller
public class IndexController {
	
	@RequestMapping(value = "/index",method = RequestMethod.GET)
    public String hello(Model model,HttpServletRequest request) {
		String token = request.getParameter("token");
		User user = new User(token);
		User.map.put(token,user);
		
		ChatConstants.addOnlines(token, user);
		model.addAttribute("curName", user.getCode());
		model.addAttribute("token", token);
        return "index";
    }
}